/**
 * <copyright>
 *
 * Copyright (c) 2011 Zeligsoft (2009) Limited
 * All rights reserved.   This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors: 
 *   Zeligsoft (2009) Limited - Initial API and implementation
 *
 * </copyright>
 *
 */
package org.omg.deployment.parts.impl;

import org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent;
import org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent;
import org.eclipse.emf.eef.runtime.api.parts.ISWTPropertiesEditionPart;
import org.eclipse.emf.eef.runtime.impl.notify.PropertiesEditionEvent;
import org.eclipse.emf.eef.runtime.impl.parts.CompositePropertiesEditionPart;
import org.eclipse.emf.eef.runtime.ui.parts.PartComposer;
import org.eclipse.emf.eef.runtime.ui.parts.sequence.BindingCompositionSequence;
import org.eclipse.emf.eef.runtime.ui.parts.sequence.CompositionSequence;
import org.eclipse.emf.eef.runtime.ui.parts.sequence.CompositionStep;
import org.eclipse.emf.eef.runtime.ui.utils.EditingUtils;
import org.eclipse.emf.eef.runtime.ui.widgets.SWTUtils;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.FocusAdapter;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.KeyAdapter;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Text;
import org.omg.deployment.parts.DeploymentViewsRepository;
import org.omg.deployment.parts.InstanceDeploymentDescriptionPropertiesEditionPart;
import org.omg.deployment.providers.DeploymentMessages;


/**
 * @author Toby McClean; Zeligsoft (2009) Limited
 * @generated
 */
public class InstanceDeploymentDescriptionPropertiesEditionPartImpl extends CompositePropertiesEditionPart implements ISWTPropertiesEditionPart, InstanceDeploymentDescriptionPropertiesEditionPart {

	protected Text id;
	protected Text name;
	protected Text node;
	protected Text source;



	/**
	 * Default constructor
	 * @param editionComponent the {@link IPropertiesEditionComponent} that manage this part
	 * @generated
	 */
	public InstanceDeploymentDescriptionPropertiesEditionPartImpl(IPropertiesEditionComponent editionComponent) {
    super(editionComponent);
  }

	/**
	 * {@inheritDoc}
	 * 
	 * @see org.eclipse.emf.eef.runtime.api.parts.ISWTPropertiesEditionPart#
	 * 			createFigure(org.eclipse.swt.widgets.Composite)
	 * @generated
	 */
	public Composite createFigure(final Composite parent) {
    view = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 3;
    view.setLayout(layout);
    createControls(view);
    return view;
  }

	/**
	 * {@inheritDoc}
	 * 
	 * @see org.eclipse.emf.eef.runtime.api.parts.ISWTPropertiesEditionPart#
	 * 			createControls(org.eclipse.swt.widgets.Composite)
	 * @generated
	 */
	public void createControls(Composite view) { 
    CompositionSequence instanceDeploymentDescriptionStep = new BindingCompositionSequence(propertiesEditionComponent);
    CompositionStep propertiesStep = instanceDeploymentDescriptionStep.addStep(DeploymentViewsRepository.InstanceDeploymentDescription.Properties.class);
    propertiesStep.addStep(DeploymentViewsRepository.InstanceDeploymentDescription.Properties.id);
    propertiesStep.addStep(DeploymentViewsRepository.InstanceDeploymentDescription.Properties.name);
    propertiesStep.addStep(DeploymentViewsRepository.InstanceDeploymentDescription.Properties.node);
    propertiesStep.addStep(DeploymentViewsRepository.InstanceDeploymentDescription.Properties.source);
    
    
    composer = new PartComposer(instanceDeploymentDescriptionStep) {

      @Override
      public Composite addToPart(Composite parent, Object key) {
        if (key == DeploymentViewsRepository.InstanceDeploymentDescription.Properties.class) {
          return createPropertiesGroup(parent);
        }
        if (key == DeploymentViewsRepository.InstanceDeploymentDescription.Properties.id) {
          return createIdText(parent);
        }
        if (key == DeploymentViewsRepository.InstanceDeploymentDescription.Properties.name) {
          return createNameText(parent);
        }
        if (key == DeploymentViewsRepository.InstanceDeploymentDescription.Properties.node) {
          return createNodeText(parent);
        }
        if (key == DeploymentViewsRepository.InstanceDeploymentDescription.Properties.source) {
          return createSourceText(parent);
        }
        return parent;
      }
    };
    composer.compose(view);
  }

	/**
	 * @generated
	 */
	protected Composite createPropertiesGroup(Composite parent) {
    Group propertiesGroup = new Group(parent, SWT.NONE);
    propertiesGroup.setText(DeploymentMessages.InstanceDeploymentDescriptionPropertiesEditionPart_PropertiesGroupLabel);
    GridData propertiesGroupData = new GridData(GridData.FILL_HORIZONTAL);
    propertiesGroupData.horizontalSpan = 3;
    propertiesGroup.setLayoutData(propertiesGroupData);
    GridLayout propertiesGroupLayout = new GridLayout();
    propertiesGroupLayout.numColumns = 3;
    propertiesGroup.setLayout(propertiesGroupLayout);
    return propertiesGroup;
  }

	/**
	 * @generated
	 */
	
	protected Composite createIdText(Composite parent) {
    SWTUtils.createPartLabel(parent, DeploymentMessages.InstanceDeploymentDescriptionPropertiesEditionPart_IdLabel, propertiesEditionComponent.isRequired(DeploymentViewsRepository.InstanceDeploymentDescription.Properties.id, DeploymentViewsRepository.SWT_KIND));
    id = new Text(parent, SWT.BORDER);
    id.setEnabled(false);
    id.setToolTipText(DeploymentMessages.InstanceDeploymentDescription_ReadOnly);
    GridData idData = new GridData(GridData.FILL_HORIZONTAL);
    id.setLayoutData(idData);
    id.addFocusListener(new FocusAdapter() {

      /**
       * {@inheritDoc}
       * 
       * @see org.eclipse.swt.events.FocusAdapter#focusLost(org.eclipse.swt.events.FocusEvent)
       * @generated
       */
      @Override
      @SuppressWarnings("synthetic-access")
      public void focusLost(FocusEvent e) {
        if (propertiesEditionComponent != null)
          propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(InstanceDeploymentDescriptionPropertiesEditionPartImpl.this, DeploymentViewsRepository.InstanceDeploymentDescription.Properties.id, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, id.getText()));
      }

    });
    id.addKeyListener(new KeyAdapter() {

      /**
       * {@inheritDoc}
       * 
       * @see org.eclipse.swt.events.KeyAdapter#keyPressed(org.eclipse.swt.events.KeyEvent)
       * @generated
       */
      @Override
      @SuppressWarnings("synthetic-access")
      public void keyPressed(KeyEvent e) {
        if (e.character == SWT.CR) {
          if (propertiesEditionComponent != null)
            propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(InstanceDeploymentDescriptionPropertiesEditionPartImpl.this, DeploymentViewsRepository.InstanceDeploymentDescription.Properties.id, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, id.getText()));
        }
      }

    });
    EditingUtils.setID(id, DeploymentViewsRepository.InstanceDeploymentDescription.Properties.id);
    EditingUtils.setEEFtype(id, "eef::Text"); //$NON-NLS-1$
    SWTUtils.createHelpButton(parent, propertiesEditionComponent.getHelpContent(DeploymentViewsRepository.InstanceDeploymentDescription.Properties.id, DeploymentViewsRepository.SWT_KIND), null); //$NON-NLS-1$
    return parent;
  }

	/**
	 * @generated
	 */
	
	protected Composite createNameText(Composite parent) {
    SWTUtils.createPartLabel(parent, DeploymentMessages.InstanceDeploymentDescriptionPropertiesEditionPart_NameLabel, propertiesEditionComponent.isRequired(DeploymentViewsRepository.InstanceDeploymentDescription.Properties.name, DeploymentViewsRepository.SWT_KIND));
    name = new Text(parent, SWT.BORDER);
    name.setEnabled(false);
    name.setToolTipText(DeploymentMessages.InstanceDeploymentDescription_ReadOnly);
    GridData nameData = new GridData(GridData.FILL_HORIZONTAL);
    name.setLayoutData(nameData);
    name.addFocusListener(new FocusAdapter() {

      /**
       * {@inheritDoc}
       * 
       * @see org.eclipse.swt.events.FocusAdapter#focusLost(org.eclipse.swt.events.FocusEvent)
       * @generated
       */
      @Override
      @SuppressWarnings("synthetic-access")
      public void focusLost(FocusEvent e) {
        if (propertiesEditionComponent != null)
          propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(InstanceDeploymentDescriptionPropertiesEditionPartImpl.this, DeploymentViewsRepository.InstanceDeploymentDescription.Properties.name, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, name.getText()));
      }

    });
    name.addKeyListener(new KeyAdapter() {

      /**
       * {@inheritDoc}
       * 
       * @see org.eclipse.swt.events.KeyAdapter#keyPressed(org.eclipse.swt.events.KeyEvent)
       * @generated
       */
      @Override
      @SuppressWarnings("synthetic-access")
      public void keyPressed(KeyEvent e) {
        if (e.character == SWT.CR) {
          if (propertiesEditionComponent != null)
            propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(InstanceDeploymentDescriptionPropertiesEditionPartImpl.this, DeploymentViewsRepository.InstanceDeploymentDescription.Properties.name, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, name.getText()));
        }
      }

    });
    EditingUtils.setID(name, DeploymentViewsRepository.InstanceDeploymentDescription.Properties.name);
    EditingUtils.setEEFtype(name, "eef::Text"); //$NON-NLS-1$
    SWTUtils.createHelpButton(parent, propertiesEditionComponent.getHelpContent(DeploymentViewsRepository.InstanceDeploymentDescription.Properties.name, DeploymentViewsRepository.SWT_KIND), null); //$NON-NLS-1$
    return parent;
  }

	/**
	 * @generated
	 */
	
	protected Composite createNodeText(Composite parent) {
    SWTUtils.createPartLabel(parent, DeploymentMessages.InstanceDeploymentDescriptionPropertiesEditionPart_NodeLabel, propertiesEditionComponent.isRequired(DeploymentViewsRepository.InstanceDeploymentDescription.Properties.node, DeploymentViewsRepository.SWT_KIND));
    node = new Text(parent, SWT.BORDER);
    node.setEnabled(false);
    node.setToolTipText(DeploymentMessages.InstanceDeploymentDescription_ReadOnly);
    GridData nodeData = new GridData(GridData.FILL_HORIZONTAL);
    node.setLayoutData(nodeData);
    node.addFocusListener(new FocusAdapter() {

      /**
       * {@inheritDoc}
       * 
       * @see org.eclipse.swt.events.FocusAdapter#focusLost(org.eclipse.swt.events.FocusEvent)
       * @generated
       */
      @Override
      @SuppressWarnings("synthetic-access")
      public void focusLost(FocusEvent e) {
        if (propertiesEditionComponent != null)
          propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(InstanceDeploymentDescriptionPropertiesEditionPartImpl.this, DeploymentViewsRepository.InstanceDeploymentDescription.Properties.node, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, node.getText()));
      }

    });
    node.addKeyListener(new KeyAdapter() {

      /**
       * {@inheritDoc}
       * 
       * @see org.eclipse.swt.events.KeyAdapter#keyPressed(org.eclipse.swt.events.KeyEvent)
       * @generated
       */
      @Override
      @SuppressWarnings("synthetic-access")
      public void keyPressed(KeyEvent e) {
        if (e.character == SWT.CR) {
          if (propertiesEditionComponent != null)
            propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(InstanceDeploymentDescriptionPropertiesEditionPartImpl.this, DeploymentViewsRepository.InstanceDeploymentDescription.Properties.node, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, node.getText()));
        }
      }

    });
    EditingUtils.setID(node, DeploymentViewsRepository.InstanceDeploymentDescription.Properties.node);
    EditingUtils.setEEFtype(node, "eef::Text"); //$NON-NLS-1$
    SWTUtils.createHelpButton(parent, propertiesEditionComponent.getHelpContent(DeploymentViewsRepository.InstanceDeploymentDescription.Properties.node, DeploymentViewsRepository.SWT_KIND), null); //$NON-NLS-1$
    return parent;
  }

	/**
	 * @generated
	 */
	
	protected Composite createSourceText(Composite parent) {
    SWTUtils.createPartLabel(parent, DeploymentMessages.InstanceDeploymentDescriptionPropertiesEditionPart_SourceLabel, propertiesEditionComponent.isRequired(DeploymentViewsRepository.InstanceDeploymentDescription.Properties.source, DeploymentViewsRepository.SWT_KIND));
    source = new Text(parent, SWT.BORDER);
    source.setEnabled(false);
    source.setToolTipText(DeploymentMessages.InstanceDeploymentDescription_ReadOnly);
    GridData sourceData = new GridData(GridData.FILL_HORIZONTAL);
    source.setLayoutData(sourceData);
    source.addFocusListener(new FocusAdapter() {

      /**
       * {@inheritDoc}
       * 
       * @see org.eclipse.swt.events.FocusAdapter#focusLost(org.eclipse.swt.events.FocusEvent)
       * @generated
       */
      @Override
      @SuppressWarnings("synthetic-access")
      public void focusLost(FocusEvent e) {
        if (propertiesEditionComponent != null)
          propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(InstanceDeploymentDescriptionPropertiesEditionPartImpl.this, DeploymentViewsRepository.InstanceDeploymentDescription.Properties.source, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, source.getText()));
      }

    });
    source.addKeyListener(new KeyAdapter() {

      /**
       * {@inheritDoc}
       * 
       * @see org.eclipse.swt.events.KeyAdapter#keyPressed(org.eclipse.swt.events.KeyEvent)
       * @generated
       */
      @Override
      @SuppressWarnings("synthetic-access")
      public void keyPressed(KeyEvent e) {
        if (e.character == SWT.CR) {
          if (propertiesEditionComponent != null)
            propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(InstanceDeploymentDescriptionPropertiesEditionPartImpl.this, DeploymentViewsRepository.InstanceDeploymentDescription.Properties.source, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, source.getText()));
        }
      }

    });
    EditingUtils.setID(source, DeploymentViewsRepository.InstanceDeploymentDescription.Properties.source);
    EditingUtils.setEEFtype(source, "eef::Text"); //$NON-NLS-1$
    SWTUtils.createHelpButton(parent, propertiesEditionComponent.getHelpContent(DeploymentViewsRepository.InstanceDeploymentDescription.Properties.source, DeploymentViewsRepository.SWT_KIND), null); //$NON-NLS-1$
    return parent;
  }



	/**
	 * {@inheritDoc}
	 * 
	 * @see org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionListener#firePropertiesChanged(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent)
	 * @generated
	 */
	public void firePropertiesChanged(IPropertiesEditionEvent event) {
  }

	/**
	 * {@inheritDoc}
	 * 
	 * @see org.omg.deployment.parts.InstanceDeploymentDescriptionPropertiesEditionPart#getId()
	 * @generated
	 */
	public String getId() {
    return id.getText();
  }

	/**
	 * {@inheritDoc}
	 * 
	 * @see org.omg.deployment.parts.InstanceDeploymentDescriptionPropertiesEditionPart#setId(String newValue)
	 * @generated
	 */
	public void setId(String newValue) {
    if (newValue != null) {
      id.setText(newValue);
    } else {
      id.setText(""); //$NON-NLS-1$
    }
  }


	/**
	 * {@inheritDoc}
	 * 
	 * @see org.omg.deployment.parts.InstanceDeploymentDescriptionPropertiesEditionPart#getName()
	 * @generated
	 */
	public String getName() {
    return name.getText();
  }

	/**
	 * {@inheritDoc}
	 * 
	 * @see org.omg.deployment.parts.InstanceDeploymentDescriptionPropertiesEditionPart#setName(String newValue)
	 * @generated
	 */
	public void setName(String newValue) {
    if (newValue != null) {
      name.setText(newValue);
    } else {
      name.setText(""); //$NON-NLS-1$
    }
  }


	/**
	 * {@inheritDoc}
	 * 
	 * @see org.omg.deployment.parts.InstanceDeploymentDescriptionPropertiesEditionPart#getNode()
	 * @generated
	 */
	public String getNode() {
    return node.getText();
  }

	/**
	 * {@inheritDoc}
	 * 
	 * @see org.omg.deployment.parts.InstanceDeploymentDescriptionPropertiesEditionPart#setNode(String newValue)
	 * @generated
	 */
	public void setNode(String newValue) {
    if (newValue != null) {
      node.setText(newValue);
    } else {
      node.setText(""); //$NON-NLS-1$
    }
  }


	/**
	 * {@inheritDoc}
	 * 
	 * @see org.omg.deployment.parts.InstanceDeploymentDescriptionPropertiesEditionPart#getSource()
	 * @generated
	 */
	public String getSource() {
    return source.getText();
  }

	/**
	 * {@inheritDoc}
	 * 
	 * @see org.omg.deployment.parts.InstanceDeploymentDescriptionPropertiesEditionPart#setSource(String newValue)
	 * @generated
	 */
	public void setSource(String newValue) {
    if (newValue != null) {
      source.setText(newValue);
    } else {
      source.setText(""); //$NON-NLS-1$
    }
  }







	/**
	 * {@inheritDoc}
	 *
	 * @see org.eclipse.emf.eef.runtime.api.parts.IPropertiesEditionPart#getTitle()
	 * @generated
	 */
	public String getTitle() {
    return DeploymentMessages.InstanceDeploymentDescription_Part_Title;
  }



}
